package com.own.business.creditbank.util;

import com.own.business.creditbank.base.BaseCreditBankRequestUtil;
import com.own.business.creditbank.function.ResolveFunctionStatic;
import com.own.business.creditbank.model.ResultVo;
import com.own.business.creditbank.model.request.AcademicEducation;
import com.own.business.creditbank.model.request.JobTraining;
import com.own.business.creditbank.model.request.NotAcademicEducation;
import com.own.business.creditbank.model.request.OnlineOpenCourse;
import com.own.business.creditbank.model.request.ResultRecord;
import com.own.business.creditbank.model.response.ResultRecordEnumResponse;
import com.own.business.creditbank.model.result.StoreInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

/**
 * CreditBankRequestUtil
 *
 * @author chenxueli
 * @date 2022-08-05 09:48:00
 */
@Slf4j
@Component
public class CreditBankRequestUtil {

    @Resource
    private BaseCreditBankRequestUtil baseCreditBankRequestUtil;

    /**
     * 学历教育信息存储
     *
     * @param list 学历教育信息列表
     * @return 响应数据
     */
    public ResultVo<List<StoreInfo>> academicEducation(List<AcademicEducation> list) {
        var map = new HashMap<String, Object>();
        map.put("list", list);
        return baseCreditBankRequestUtil.request("/credit/open/degreeLicense", map, ResolveFunctionStatic.STORE_INFO_RESOLVE);
    }

    /**
     * 职业培训信息存储
     *
     * @param list 职业培训信息列表
     * @return 响应数据
     */
    public ResultVo<List<StoreInfo>> jobTraining(List<JobTraining> list) {
        var map = new HashMap<String, Object>();
        map.put("list", list);
        return baseCreditBankRequestUtil.request("/credit/open/tranLicense", map, ResolveFunctionStatic.STORE_INFO_RESOLVE);
    }

    /**
     * 非学历信息存储
     *
     * @param list 非学历信息列表
     * @return 响应数据
     */
    public ResultVo<List<StoreInfo>> notAcademicEducation(List<NotAcademicEducation> list) {
        var map = new HashMap<String, Object>();
        map.put("list", list);
        return baseCreditBankRequestUtil.request("/credit/open/otherDegreeLicense", map, ResolveFunctionStatic.STORE_INFO_RESOLVE);
    }

    /**
     * 在线开放课程信息存储
     *
     * @param list 在线开放课程信息列表
     * @return 响应数据
     */
    public ResultVo<List<StoreInfo>> onlineOpenCourse(List<OnlineOpenCourse> list) {
        var map = new HashMap<String, Object>();
        map.put("onlineResultVo", list);
        return baseCreditBankRequestUtil.request("/credit/open/onlineLicense", map, ResolveFunctionStatic.STORE_INFO_RESOLVE);
    }

    /**
     * 成果信息枚举值
     *
     * @return 响应数据
     */
    public ResultVo<ResultRecordEnumResponse> resultRecordEnum() {
        return baseCreditBankRequestUtil.request("/credit/open/licenseEnum", new HashMap<>(), ResultRecordEnumResponse.RESOLVE);
    }

    /**
     * 成果转换信息存储
     *
     * @param list 成果转换信息列表
     * @return 响应数据
     */
    public ResultVo<Boolean> resultRecord(List<ResultRecord> list) {
        var map = new HashMap<String, Object>();
        map.put("list", list);
        return baseCreditBankRequestUtil.request("/credit/open/tranRecord", map, ResolveFunctionStatic.BOOLEAN_RESOLVE);
    }

    /**
     * 用户积分查询
     *
     * @param idCardNo 身份证号信息
     * @return 积分信息
     */
    public ResultVo<BigDecimal> userScore(String idCardNo) {
        var map = new HashMap<String, Object>(8);
        map.put("idCard", idCardNo);
        return baseCreditBankRequestUtil.request("/credit/open/userScore", map, ResolveFunctionStatic.BIG_DECIMAL_RESOLVE);
    }

}
